lib/deploy: skip fallocate call when requested size is 0
authorDusty Mabe <dusty@dustymabe.com>
Thu, 1 Jun 2023 13:23:41 +0000 (09:23 -0400)
committerDusty Mabe <dusty@dustymabe.com>
Thu, 1 Jun 2023 13:25:35 +0000 (09:25 -0400)
If the requested size is 0 then of course we have enough room ðŸ™‚

This avoids the fallocate call returning an EINVAL.

Closes: #2869
src/libostree/ostree-sysroot-deploy.c

index c5ced04c0aa1a3eded6331700ba7319d3801553d..d63047345683540cdb8d03affef7067be2e7a78a 100644 (file)
@@ -2446,6 +2446,14 @@ get_kernel_layout_size (OstreeSysroot *self, OstreeDeployment *deployment, guint
 static gboolean
 dfd_fallocate_check (int dfd, __off_t len, gboolean *out_passed, GError **error)
 {
+  /* If the requested size is 0 then return early. Passing a 0 len to
+   * fallocate results in EINVAL */
+  if (len == 0)
+    {
+      *out_passed = TRUE;
+      return TRUE;
+    }
+
   g_auto (GLnxTmpfile) tmpf = {
     0,
   };